class EventListener:
    def __init__(self):
        self.callbacks = []

    def register_callback(self, callback):
        self.callbacks.append(callback)

    def trigger_event(self, event_data):
        print (self.callbacks)
        for callback in self.callbacks:
            callback(event_data)


class AnotherClass:
    def __init__(self, event_listener):
        self.event_listener = event_listener

    def on_event_triggered(self, event_data):
        print(f"Event occurred: {event_data}")

    def register_for_event(self):
        self.event_listener.register_callback(self.on_event_triggered)


# 创建事件监听器
event_listener = EventListener()

# 创建另一个类的实例并注册回调函数
another_instance = AnotherClass(event_listener)
another_instance.register_for_event()

# 模拟事件触发
event_listener.trigger_event()
